﻿
<div class="form-horizontal" ms-controller="KCGL">
    <div style="margin: 0 80px;">
        <div>
            <ul class="clearfix" style="display: block;padding:0">
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>课程分类</label>
                    <div class="add-ic">
                        <select class="form-control szhl_require" ms-duplex="modelData.KCTypeID">
                            <option ms-repeat-el="TypeData" ms-attr-selected="modelData.KCTypeID==el.ID?'selected':''" ms-attr-value="el.ID">{{el.TypeName}}</option>
                        </select>
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>课程名称</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_require" ms-duplex="modelData.KCName" />
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>培训课件</label>
                    <div class="add-ic">
                        <textarea type="search" class="form-control" ms-duplex="SelKJName" onfocus="this.blur()" placeholder="请选择课件"></textarea>
                        <input type="hidden" ms-duplex="modelData.KJID" />

                        <a ms-click="SelKJ()" class="btn btn-primary" style="margin-top:5px;">从课件库中选择</a>
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label">授权类型</label>
                    <div class="add-ic">
                        <select class="form-control szhl_require" ms-duplex="modelData.SQType">
                            <option ms-attr-selected="modelData.SQType=='公开'?'selected':''">公开</option>
                            <!--<option ms-attr-selected="modelData.SQType=='审批'?'selected':''">审批</option>
                            <option ms-attr-selected="modelData.SQType=='凭密码'?'selected':''">凭密码</option>
                            <option ms-attr-selected="modelData.SQType=='隐藏'?'selected':''">隐藏</option>-->
                        </select>
                    </div>
                </li>
                <li class="add-item add-width  fl-left">
                    <label class="add-item-label"><i>*</i>主讲人姓名</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_require" ms-duplex="modelData.KCZJR" />
                    </div>
                </li>
                <li class="add-item add-width fl-right">
                    <label class="add-item-label"><i>*</i>主讲人职称</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_require" ms-duplex="modelData.KCZJRZC" />
                    </div>
                </li>

                <li class="add-item add-width  fl-left">
                    <label class="add-item-label"><i>*</i>培训课时(小时)</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_require" ms-duplex="modelData.KSS" />
                    </div>
                </li>
                <li class="add-item add-width fl-right">
                    <label class="add-item-label">培训周期</label>
                    <div class="add-ic">
                        <input type="text" class="form-control " ms-duplex="modelData.KCPXZQ" />
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label">课程封面</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_Upload" ms-duplex="modelData.KCFM" />
                    </div>
                </li>

                <li class="add-item add-widthall">
                    <label class="add-item-label">备注简介</label>
                    <div class="add-ic">
                        <textarea ms-duplex="modelData.Remark" rows="4" id="kcgl" class="form-control  szhl_UEEDIT"></textarea>
                    </div>
                </li>
            </ul>
        </div>

    </div>
</div>

<script>
    var tempmodel = avalon.define({
        $id: "KCGL",
        name: "课程管理",
        iswf: true,//是否属于流程表单 
        TypeData: [],
        KJData: [],
        inittemp: function (strId) {
            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETZIDIANLIST', { P1: 24 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.TypeData = resultData.Result;
                    if (!tempmodel.modelData.KCTypeID) {
                        tempmodel.modelData.KCTypeID = resultData.Result[0].ID
                    };
                }
            })
            if (strId) {
                //编辑加载数据
                $.getJSON('/API/VIEWAPI.ashx?Action=KCGL_GETKCGLMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        tempmodel.SelKJName = resultData.Result1;
                        setTimeout(" ComFunJS.initForm()", 500);

                    }
                })
            } else {
                ComFunJS.initForm();
            }  
        },//初始化
        modelData: { "KCTypeID": "", "KCName": "", "KCZJR": "", "KCZJRZC": "", "KSS": "", "KCPXZQ": "", "SQType": "公开", "Remark": "", "KJID": "", "KCFM": "" },
        SaveData: function (callback) {
            $.post("/API/VIEWAPI.ashx?ACTION=KCGL_ADDKCGL", { P1: JSON.stringify(tempmodel.modelData.$model) }, function (result) {
                return callback.call(this, $.parseJSON(result));
            });
        }, SelKJName: "", SelKJ: function () {

            top.ComFunJS.winbtnwin("/ViewV5/AppPage/KCGL/KJGLSelect.html?checkvalue=" + tempmodel.modelData.KJID, "选择课件", 900, 470, {}, function (layero, index) {
                var frameid = $("iframe", $(layero)).attr('id');
                var nowwin = ComFunJS.isIE() ? top.window.frames[frameid] : top.window.frames[frameid].contentWindow;
                var data = nowwin.GetSelKJData();
                if (data.length == 0) {
                    top.ComFunJS.winwarning("请选择课件");
                    return;
                }
                var Ids = "";
                var names = "";
                $(data).each(function (i, val) {
                    names += val.KJName + "，";
                    Ids += val.ID + ",";
                })
                tempmodel.SelKJName = names.substring(0, names.length - 1);
                tempmodel.modelData.KJID = Ids.substring(0, Ids.length - 1);
                top.layer.close(index)
            })
        }, DELKJZZ: function (item) {
            tempmodel.SelKJData.remove(item);
        }

    });

    tempmodel.$watch("modelData.*", function (a, b) {
        if (!tempmodel.modelData.ID) {
            localStorage.setItem(pmodel.FormCode, JSON.stringify(tempmodel.modelData.$model));
        }
    })//@ sourceURL=KCGL.js;

</script>
